// pages/TradingAreaCenter/components/shopDetail/123.js
const controller = require("../../../controllers/Controller").controller

Component({
  /**
   * 组件的属性列表
   */
  properties: {
    shopId:{
      type:Number,
      value: 0
    }
  },
  data:{
    detail:{}
  },
  observers: {
    'shopId': function (id) {
      this.getDetail(id)
    }
  },
  methods: {
    //打开地址
    openAddress(e) {
      var lng = this.data.detail.lng || '';
      var lat = this.data.detail.lat || '';
      wx.openLocation({
        //当前经纬度
        latitude: Number(lat),
        longitude: Number(lng),
        //缩放级别默认28
        scale: 28,
      })
    },
    //打电话
    calling() {
      let phone = this.data.detail.mobile
      wx.makePhoneCall({
        phoneNumber: phone,
        success: function () {
          console.log("拨打电话成功！")
        },
        fail: function () {
          console.log("拨打电话失败！")
        }
      })
    },
    closeDialog() {
      this.triggerEvent('closeDetail')
    },
    getDetail(id){
      controller.getShopDetail({shopId:id}).then(res=>{
        res.data.label = res.data.label.split('/')
        console.log(res.data.label);
        this.setData({
          detail:res.data
        })
      })
    }
  },
  
})
